<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        *{
            margin: 0px;
            padding: 0px;
        }
        html,body{
            width: 100%;
            height: 100%;
        }
        .container{
            width: 50%;
            height: 50%;
            background-color: #004b00;
            color: red;
            font-size: 12px;
        }
    </style>
</head>
<body>
<div class="container"></div>

</body>
<script>
    function getPage() {
        return "哈哈"
    }
    function isOverFlow(container) {
        if(container.scrollHeight>container.clientHeight)
        {
            return true
        }
        return false
    }
    test()
    function test()
    {
        let container=document.querySelector(".container")
        while (true)
        {
            let word=getPage()
            let html=container.innerHTML
            container.innerHTML=word+html
            if(isOverFlow(container))
            {
                container.innerHTML=html
                break
            }
        }
        console.log("结束添加字符")
    }

</script>
</html>